#include <iostream>
#include <cstdio>
#include <string>
#include <unordered_map>
using namespace std;

int main() {
    string s;
    getline(cin, s);
    char ch;
    cin >> ch;
    unordered_map<char, int> hash;
    for (auto c : s)
    {
        if (isupper(c))
            c = tolower(c);
        hash[c]++;
    }
    cout << hash[tolower(ch)] << endl;
    return 0;
}